<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var str = "aaabbcdde";
      var str2 = "sfhshfhfjkshdsh";
      function norepeat_count(str) {
        var obj = {};
        var newstr = "";
        for (var i = 0; i < str.length; i++) {
          obj[str[i]] = 0; //初始化对象
          if (newstr.indexOf(str[i]) == -1) {
            newstr += str[i];
          } //去重
        }
        for (var i = 0; i < str.length; i++) {
          for (var key in obj)
            if (str[i] == key) {
              obj[key] += 1;
            }
        }
        console.log(obj);
        return newstr;
      }

      console.log(norepeat_count(str));
      console.log(norepeat_count(str2));
    </script>
  </body>
</html>
